<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>生命周期</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>n 的值为：{{ n }}</div>
        <button @click="n += 1">add n</button>
        <button @click="$destroy()">销毁</button>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                n: 0
            },
            beforeCreate() {
                console.log('beforeCreate')
            },
            created() {
                console.log('created')
            },
            beforeMount() {
                console.log('beforeMount')
            },
            mounted() {
                console.log('mounted')
            },
            beforeUpdate() {
                console.log('beforeUpdate')
            },
            updated() {
                console.log('updated')
            },
            beforeDestroy() {
                console.log('beforeDestroy')
            },
            destroyed() {
                console.log('destroyed')
            }
        })
    </script>
</body>
</html>